
/**
 * Module dependencies.
 */

var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var page0 = require('./routes/page0');
var page1 = require('./routes/page1');
var page2 = require('./routes/page2');
var page3 = require('./routes/page3');
var http = require('http');
var path = require('path');
//var test = require('./test');

var app = express();

// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.engine('html', require('ejs').renderFile);
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));

// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}

app.get('/', routes.index);
app.get('/users', user.list);
app.get('/page0', page0.index);
app.get('/page1', page1.index);
app.post('/page2', page2.index);
app.post('/page3', page3.index);
app.post('/getjson', page1.getjson);

//app.post('/users', user.list);
//app : express 서버
//get :  get / post 사용가능
//'/users' : REST 방식의 주소 ex) test:3000/    app.get('주소', 사용파일내의 함수); 
// user.list : user.js 파일에서... export.(list) 있는 function 사용하겠다.

http.createServer(app).listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));
});
